package JavaBaseTest;

/**
 * @program: java_learning
 * @description
 * @author: 辛旭初
 * @create: 2021-11-11 23:34
 **/

public class Test1111 {


    public static void main(String[] args) {


//
        int[] arra = new int[]{-98,-34,0,12,16,18,34};
//        //二分法的代码
//        int dest = 34;
//        int head = 0 ;
//        int end = arra.length-1;
//
//        while (head <= end){
//            int middle = (head + end )/2;
//            if (dest == arra[middle]){
//                System.out.println("找到当前数组下标为："+middle);
//                break;
//            }else if (arra[middle] > dest){
//                 end = middle -1;
//            }else {
//                head = middle +1 ;
//            }
//        }

        //冒泡排序法
        for (int i = 0; i < arra.length -1; i++ ){

            for (int j=0;j<arra.length-1-i;j++){
                if (arra[j] >arra[j+1]){
                    int temp = arra[j];
                    arra[j] = arra[j+1];
                    arra[j+1] = temp; 
                }
            }
        }
    }
}
